<?php
namespace App\Http\Controllers\Api\V1\Resources;

use Illuminate\Http\Resources\Json\JsonResource;

class AttributeGroupResource extends JsonResource
{
    public function toArray($request)
    {
    	$data = $this->resource;
    	
        $data = [
        	'id' => (int)$data->id,
	        'title' => $data->title ?? '',
	        'created_at' => (string)$data->created_at,
	        
	        'attribute_keys' => AttributeKeyResource::collection($this->whenLoaded('attributeKeys')),
        ];
        
        return $data;
    }
}
